 function  getbutton() {
           
    var id = $("#user-id").val();
    $.ajax({
            url: 'http://localhost:8080/nfa/index.php/friend/getbutton', // form action url
            type: 'POST', // form submit method get/post
            dataType: 'html', // request type html/json/xml
            data:{id : id}, // serialize form data 

            success: function(data) {
                  $("#btn-friend").html(data);
            },
            error: function(e) {
                console.log(e);
            }

        });
        setTimeout('getbutton()', 500);
 }
 
 function addfriend(){
           var id = $("#user-id").val();
    $.ajax({
            url: 'http://localhost:8080/nfa/index.php/friend/request', // form action url
            type: 'POST', // form submit method get/post
            dataType: 'html', // request type html/json/xml
            data:{id : id}, // serialize form data 

            success: function(data) {
                  
            },
            error: function(e) {
                console.log(e);
            }

        });
 }
  function unfriend(){
           var id = $("#user-id").val();
    $.ajax({
            url: 'http://localhost:8080/nfa/index.php/friend/unfriend', // form action url
            type: 'POST', // form submit method get/post
            dataType: 'html', // request type html/json/xml
            data:{id : id}, // serialize form data 

            success: function(data) {
                  
            },
            error: function(e) {
                console.log(e);
            }

        });
 }

  function cancelRequest(){
           var id = $("#user-id").val();
    $.ajax({
            url: 'http://localhost:8080/nfa/index.php/friend/cancelRequest', // form action url
            type: 'POST', // form submit method get/post
            dataType: 'html', // request type html/json/xml
            data:{id : id}, // serialize form data 

            success: function(data) {
                  console.log(data);
            },
            error: function(e) {
                console.log(e);
            }

        });
 }
 function searchSubmit(){
     $("#sb").submit();
 }
 
 function joindating(id,dating_id){
      $.ajax({
            url: 'http://localhost:8080/nfa/index.php/dating/joindating', // form action url
            type: 'POST', // form submit method get/post
            dataType: 'html', // request type html/json/xml
            data:{
                id : id,
                id_dating : dating_id
            }, 
            success: function(data) {
                  
            },
            error: function(e) {
                console.log(e);
            }

        });
 }
 
 function clicknotification(id){
         $.ajax({
            url: 'http://localhost:8080/nfa/index.php/dating/clicknotification', // form action url
            type: 'POST', // form submit method get/post
            dataType: 'html', // request type html/json/xml
            data:{
                id : id
                
            }, 
            success: function(data) {
                  
            },
            error: function(e) {
                console.log(e);
            }

        });
 }
 
 function updateavarta(){
     var file = $('#uploadphoto').val();
       $.ajax({
            url: 'http://localhost:8080/nfa/index.php/user/uploadavarta', // form action url
            type: 'POST', // form submit method get/post
            dataType: 'html', // request type html/json/xml
            data:{
                file : file
                
            }, 
            success: function(data) {
                  
            },
            error: function(e) {
                console.log(e);
            }

        });
 }
 
  function readURL(input) {
                if (input.files && input.files[0]) {
                    var reader = new FileReader();

                    reader.onload = function(e) {
                        $('#img_prev').attr('src', e.target.result)
                                .width(120)
                                .height(120);
                    };
                    reader.readAsDataURL(input.files[0]);
                }
            }
            function cleanphoto() {
                $(".photo").empty();
            }
            function loadnotice() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/dating/loadnotification",
                    success: function(data) {
                        $("#notice").empty();
                        $("#notice").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('loadnotice()', 500); // Every 15 seconds.
            }
            function updatenotice() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/dating/checknotice",
                    success: function(data) {
                        $("#count-notice").empty();
                        $("#count-notice").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('updatenotice()', 1000); // Every 15 seconds.

            }


            function zoomphoto(id) {

                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/photo/getphoto",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {
                        $(".photo").html(data);


                    }
                });



            }
            function loadphoto(id) {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/photo/loadphoto",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {
                        $("#loadphoto").html(data);

                    }
                });

            }
            function deletephoto(id) {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/photo/deletephoto",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {

                    }
                });

            }
            function deletealbum(id) {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/photo/deletealbum",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {
                        window.location = "http://localhost:8080/nfa/index.php/home/mypage";
                    }
                });

            }

            function  getbutton() {

                var id = $("#user-id").val();
                $.ajax({
                    url: 'http://localhost:8080/nfa/index.php/friend/getbutton', // form action url
                    type: 'POST', // form submit method get/post
                    dataType: 'html', // request type html/json/xml
                    data: {id: id}, // serialize form data 

                    success: function(data) {
                        $("#btn-friend").html(data);
                    },
                    error: function(e) {
                        console.log(e);
                    }

                });
                setTimeout('getbutton()', 500);

            }

            function  agree(id) {


                $.ajax({
                    url: 'http://localhost:8080/nfa/index.php/friend/agree', // form action url
                    type: 'POST', // form submit method get/post
                    dataType: 'html', // request type html/json/xml
                    data: {id: id}, // serialize form data 

                    success: function(data) {

                    },
                    error: function(e) {
                        console.log(e);
                    }

                });

            }
            var myvar;

            function updateRequest() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/friend/checkrequest",
                    success: function(data) {
                        $("#request").empty();
                        $("#request").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('updateRequest()', 1000); // Every 15 seconds.
            }
            function getRequest() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/friend/getrequest",
                    success: function(data) {
                        $("#friend-request").empty();
                        $("#friend-request").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('getRequest()', 500); // Every 15 seconds.
            }

            function updateAlerts() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/message/checkmessage",
                    success: function(data) {
                        $("#count-message").empty();
                        $("#count-message").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('updateAlerts()', 1000); // Every 15 seconds.

            }
            function updateconversations() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/message/getconversations",
                    success: function(data) {
                        $("#coversations").empty();
                        $("#coversations").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('updateconversations()', 500); // Every 15 seconds.

            }

            function updatemessage(id) {

                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/message/getmessage",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {
                        $("#tinnhan").html(data);
                        $("#id-chat").val(id);

                    }
                });
                myvar = setTimeout(function() {
                    updatemessage(id);
                }, 500);
                ;


            }
            function myStopFunction() {
                clearTimeout(myvar);
            }
            function updatestt(id) {

                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/message/updatestt",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {


                        //
                        // Do something similar for unreadMessages, if required...
                    }
                });

            }






